#################################################
###### Replication Code for Figure A8 + A9 ######
########### January 9th, 2025 ###################
#################################################

rm(list=ls())

### Script produces Figures A8 + A9 and saves them in the `/figures` folder


######## Load Data
library(fixest)
library(modelsummary)
library(dplyr)
library(ggplot2)
df <- readRDS("data/workfile.rds")

##### Figures A8 + A9
ggplot(df, aes(x = trust_in_opposing_parties)) +
  geom_histogram(color="black", fill = "black",
                 binwidth = 0.5) +
  xlab("Trust in opposing parties") + 
  ylab("Number of observations") + 
  theme_bw()

ggsave("figures/FigA8_overall_dist_dv.pdf", 
       height = 4, width = 6)

ggplot(df, aes(x = trust_in_opposing_parties)) +
  geom_histogram(color="black", fill = "black",
                 binwidth = 0.5) +
  xlab("Trust in opposing parties") + 
  ylab("Number of observations") + 
  facet_wrap(~ dem_country_code, nrow = 5) +
  theme_bw()

ggsave("figures/FigA9_country_dist_dv.pdf", 
       height = 10, width = 8)

